package com.atguigu.tingshu.common.thread;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.task.TaskDecorator;

/**
 * @Author: chenyangu
 * @Date: 2021/8/16 17:05
 * @Description: zipkin装饰器
 */


@Slf4j

public class ZipkinTaskDecorator implements TaskDecorator {

    private ZipkinHelper zipkinHelper;

    /**
     * zipkin任务装饰器
     *
     * @param zipkinHelper 拉链助手
     */
    public ZipkinTaskDecorator(ZipkinHelper zipkinHelper) {

        this.zipkinHelper = zipkinHelper;

    }

    /**
     * 装饰
     *
     * @param runnable 可运行的
     * @return {@link Runnable}
     */
    @Override

    public Runnable decorate(Runnable runnable) {

        return zipkinHelper.wrap(runnable);

    }

}
